var TextBox = function(l,field){
	var inp;
	var lbl;
	var comp = $('<div/>');  
	var self = this;
	var f = field;
	this.hasField = true;
	
	var create = function(){
		inp = $('<input type="text"/>');
		lbl = $('<label/>');
		inp.css("width","200px");
		inp.css("height","17px");
		if( l ){
			lbl.text(l + ":");
		}
		if( comp.attr('type') == 'number' ){
			inp.keypress(function(e){
				return onlyNumber(e);
			});
		}
		comp.addClass('textbox');
		var dvLbl = $('<div/>');
		dvLbl.append(lbl);
		var dvInp = $('<div/>');
		dvInp.append(inp);

		comp.append(dvLbl);
		comp.append(dvInp);
		
	};
	
	this.getField = function(){
		return f;
	};
	
	this.width = function(w){
		inp.css("width",w);
	};
	
	this.height = function(h){
		inp.css("height",h);
	};
	
	this.maxLength = function(v){
		if( v ){
			inp.attr("maxlength",v);
		}else{
			return inp.attr("maxlength");
		}
	};
	
	this.bind = function(e){
		$(e).append(comp);
	};
	
	this.value=function(v){
		if( v ){
			inp.val(v);
		}else{
			return inp.val();
		}
	};
	
	this.label = function(v){
		if( v ){
			lbl.text(v + ":");
		}else{
			return lbl.text();
		}
	};
	
	this.clear = function(){
		inp.val(null);
	};
	
	var onlyNumber = function(e){
		var numericExpression = /^[0-9]+$|\,/;
		var val = String.fromCharCode(e.charCode);
		if(val.match(numericExpression)){
			return true;
		}else{
			return false;
		}
	};
	
	create();
};

